Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
Title Install a temporary font
Keywords fonts, install font, create font, remove font, uninstall font, temporary font
Categories Utilities, Windows, Graphics
 
By Andy Fielding.

Create a BAS (or CLS) module and add the following code to it:

 
' These subs temporarily install and uninstall a font
' for use while your program is running. You MUST
' call this code to install the font before loading
' any form that uses it, or you'll generate an error.
'
' For the sFontFile argument you pass to the subs, be sure
' to use the font's actual filename (e.g. "GOUDOS.TTF"), not
' its font name (e.g. "Goudy Old Style").

Private Declare Function AddFontResource Lib "gdi32" Alias _
    "AddFontResourceA" (ByVal lpFileName As String) As Long

Private Declare Function RemoveFontResource Lib "gdi32" _
    Alias "RemoveFontResourceA" (ByVal lpFileName As _
    String) As Long

' To add the font
Public Sub AddFont(ByVal sFontFile As String)
Dim lResult As Long

    ' e.g.: lResult = AddFontResource("c:\myApp\myFont.ttf")
    lResult = AddFontResource(sFontFile)
End Sub

' To remove the font
Public Sub RemoveFont(ByVal sFontFile As String)
Dim lResult As Long

    ' e.g.: lResult =
    ' RemoveFontResource("c:\myApp\myFont.ttf")
    lResult = RemoveFontResource(sFontFile)
End Sub
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated